package com.app.activitys;

import java.io.Serializable;
import java.util.List;

import com.app.activitys.adapters.AdapterBar;
import com.app.activitys.adapters.AdapterShow;
import com.app.entidades.Bar;
import com.app.entidades.Show;
import com.example.applucianokikao.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class ActivityShow extends Activity implements OnItemClickListener{

	private ListView lista;
	private List<Show> listaShows;
	private AdapterShow adapterShow;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show);
		
		Bundle extras = getIntent().getExtras();
		Bundle valor = extras.getBundle("show");
		listaShows = (List<Show>) valor.getSerializable("shows");
		
		adapterShow = new AdapterShow(this, 0, listaShows);
		adapterShow.setNotifyOnChange(true);
		
		lista = (ListView) findViewById(R.id.listaShows);
		lista.setAdapter(adapterShow);
		lista.setOnItemClickListener((OnItemClickListener)this);
		lista.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		Intent intent = new Intent(ActivityShow.this, ActivityDetalhesShow.class);
		Show show = listaShows.get(arg2);
		Bundle bundle = new Bundle();
		bundle.putSerializable("show_objeto", (Serializable)show);
		intent.putExtra("show_bundle", bundle);	
		startActivity(intent);
	}
}
